#include "ProfileLogHandler.h"
#include "EngineLog.h"

void ProfileLogHandler::BeginOutput()
{
  EngineLog::Get().Write(LOG_APP,IDS_PROFILE_HEADER1);
  EngineLog::Get().Write(LOG_APP,IDS_PROFILE_HEADER2);
}

void ProfileLogHandler::EndOutput()
{
  EngineLog::Get().Write(LOG_APP, "\n");
}

void ProfileLogHandler::Sample(float fMin, float fAvg, float fMax, int callCount, std::string name, int parentCount)
{
  char namebuf[256], indentedName[256];
  char avg[16], min[16], max[16], num[16];

  sprintf_s(avg, 16, "%3.1f", fAvg);
  sprintf_s(min, 16, "%3.1f", fMin);
  sprintf_s(max, 16, "%3.1f", fMax);
  sprintf_s(num, 16, "%d",   callCount);

  strcpy_s(indentedName, 256, name.c_str());
  for( int indent=0; indent<parentCount; ++indent )
  {
    sprintf_s(namebuf, 256, " %s", indentedName);
    strcpy_s(indentedName, 256, namebuf);
  }

  EngineLog::Get().Write(LOG_APP,IDS_PROFILE_SAMPLE,min,avg,max,num,indentedName);
}
